<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://dolphinphp.com
// +----------------------------------------------------------------------
// | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

namespace app\shop\model;

use think\Model;
use util\Tree;


class Shop extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = '__SHOP__';

    // 自动写入时间戳
    protected $autoWriteTimestamp = true;

   public function getShopInfo($map=[]){

       $data_list = self::view('shop', true)
           ->view('business_license','businesslicenseno,effectivetime,scope,registeredcapital,organizationcode,generaltaxpayerproof,name bname,taxcode,taxno,effectiveimg,taximg,organizationcodeimg,shoppersoncodeimg,cardimg,createtime ct,updatetime ut'
               ,'business_license.shopid=shop.id','left')
           ->view('member','name mname','member.id=shop.memberid','left')
           ->where($map)
           ->find();
       foreach ($data_list as $key=>$value){
           $data_list['password']='';
       }
       return $data_list;
   }

    // 一个店铺数据 sky
    public function getShopBaseInfo($shop_id)
    {
        $shop_id = intval($shop_id);
        if($shop_id==0) return false;
        $data = self::get($shop_id);
        return is_object($data) ? $data->toArray() : array();
    }

    static public $instance = null;
    static public function getinstance()
    {
        if(is_null(self::$instance)) self::$instance = new self();
        return self::$instance;
    }

    //全部店铺
    public function getAllShop($where = [], $order = ''){
      $data_list = self::where($where)->order($order)->select();
      return $data_list;
    }


}